Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(turborepo): Improve package changes watcher performance #8064

Merged
merged 5 commits into from
May 7, 2024

Conversation

NicholasLYang
Copy link
Contributor

@NicholasLYang NicholasLYang commented Apr 30, 2024

Description

Like #8036, we need to split out the event processing loop from the actual logic to avoid lagging channels. In this case we process the changed files every 100ms.

Uses a Trie to store the paths since they'll likely have a lot of overlap.

Testing Instructions

Closes TURBO-2921

Copy link

vercel bot commented Apr 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-gatsby-web 🔄 Building (Inspect) Visit Preview 💬 Add feedback May 7, 2024 5:44pm
examples-nonmonorepo ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 7, 2024 5:44pm
examples-svelte-web 🔄 Building (Inspect) Visit Preview 💬 Add feedback May 7, 2024 5:44pm
examples-tailwind-web 🔄 Building (Inspect) Visit Preview 💬 Add feedback May 7, 2024 5:44pm
rust-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 7, 2024 5:44pm
5 Ignored Deployments
Name Status Preview Comments Updated (UTC)
examples-basic-web ⬜️ Ignored (Inspect) Visit Preview May 7, 2024 5:44pm
examples-designsystem-docs ⬜️ Ignored (Inspect) Visit Preview May 7, 2024 5:44pm
examples-kitchensink-blog ⬜️ Ignored (Inspect) Visit Preview May 7, 2024 5:44pm
examples-native-web ⬜️ Ignored (Inspect) Visit Preview May 7, 2024 5:44pm
examples-vite-web ⬜️ Ignored (Inspect) Visit Preview May 7, 2024 5:44pm

Copy link
Contributor

github-actions bot commented Apr 30, 2024

🟢 Turbopack Benchmark CI successful 🟢

Thanks


let changed_packages = change_mapper.changed_packages(changed_files.clone(), None);

tracing::warn!("changed_files: {:?}", changed_files);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warn is probably not the right level semantically, but debug has so much stuff in it and we don't log it out by default

changed_pkgs
);
}
interval.tick().await;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100ms should be enough time that we don't need to park/notify, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think that should be ok. We can ITG once the feature is stable.

Copy link
Contributor

github-actions bot commented Apr 30, 2024

🟢 CI successful 🟢

Thanks

Copy link
Contributor

@gsoltis gsoltis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few questions, but other than that ship it

changed_pkgs
);
}
interval.tick().await;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think that should be ok. We can ITG once the feature is stable.

crates/turborepo-lib/src/package_changes_watcher.rs Outdated Show resolved Hide resolved
let changed_files: HashSet<_> = trie
.keys()
.filter_map(|p| {
let p = AbsoluteSystemPathBuf::try_from(p.as_path()).ok()?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be .expect("filewatching returns absolute paths")?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to crash the daemon on this? That seems a little drastic

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so. These paths are coming from filewatching, right? If that system isn't giving us what we expect, it's a programming error on our part and lots of things will be broken. I think in that scenario, crashing is the right thing to do.

})
.filter(|p| {
// If in .gitignore or in .git, filter out
!(ancestors_is_ignored(&root_gitignore, p) || is_in_git_folder(p))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect that at some point this'll be an issue w/ inputs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah there's a subsequent PR that hooks up file hashing and removes this check

@NicholasLYang NicholasLYang force-pushed the nicholasyang/package-change-watcher-perf branch from d510c4c to c19392a Compare May 7, 2024 17:18
Copy link
Contributor Author

NicholasLYang commented May 7, 2024

@NicholasLYang NicholasLYang enabled auto-merge (squash) May 7, 2024 17:35
@NicholasLYang NicholasLYang merged commit dd837ad into main May 7, 2024
54 checks passed
@NicholasLYang NicholasLYang deleted the nicholasyang/package-change-watcher-perf branch May 7, 2024 18:10
Neosoulink pushed a commit to Neosoulink/turbo that referenced this pull request Jun 14, 2024
…cel#8064)

### Description

Like vercel#8036, we need to split out the event processing loop from the
actual logic to avoid lagging channels. In this case we process the
changed files every 100ms.

Uses a `Trie` to store the paths since they'll likely have a lot of
overlap.

### Testing Instructions

<!--
  Give a quick description of steps to test your changes.
-->


Closes TURBO-2921
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants